//
//  Setup.m
//  battlebikes
//
//  Created by Michiel de Mare on 2/Jan/2009.
//  Copyright inglua 2009. All rights reserved.
//

#import "Setup.h"
#import "Race.h"

@implementation Setup

@synthesize races,appDelegate,picker;



// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    races = [[NSArray alloc] initWithObjects:@"Osdorp Outrage", @"Bijlmer Breakout", @"Red Light Rampage", @"Museum Mayhem", @"Northern Nightmare", @"Merry Ferry", nil];
    return self;
}

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/


/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (IBAction)buttonClicked:(id)sender {
    Race *vc = [[Race alloc] initWithNibName:@"Race" bundle:nil];
    [appDelegate.window addSubview:vc.view];
    vc.raceName = [races objectAtIndex:[picker selectedRowInComponent:0]];
}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
    return 1;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
    return [races count];
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
    return [races objectAtIndex:row];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}


- (void)dealloc {
    [super dealloc];
}

@end
